function fullWidthLayout (items) {
  let width = items.width - 50
  let currentHeight = 0
  items.charts.forEach(function (element) {
    if (element.canMove && element.canResize) {
      element.width = width
      element.height = element.width * element.whfactor
      element.left = 0
      element.top = currentHeight
    }else {
      // element.left = 0
      // element.top = currentHeight
      return
    }

    currentHeight += element.height + 5
  })
  return items
}

function halfWidthLayout (items, col) {
  items.col=2
  return customerLayout(items)
}

function customerLayout (items) {
  let width = items.width - 50
  let col=items.col
  let currentTop = 0
  let currentleft = 0
 
  let correntCol = 0
  let colWidth = width / col - 6
  let maxColHeight=0
  items.charts.forEach(function (element) {
    if (element.canMove && element.canResize) {
      element.width = colWidth
      element.height = element.width * element.whfactor
      element.left = currentleft
      element.top = currentTop
    }else {
      // element.left = 0
      // element.top = currentHeight
      return
    }

    maxColHeight=Math.max(maxColHeight, element.height)
    if (correntCol >= col - 1) {
      currentTop += maxColHeight + 5
      currentleft = 0
      correntCol = 0
    }else {
      currentleft += colWidth + 6
      correntCol++
    }
  })
  return items
}

export { fullWidthLayout, halfWidthLayout, customerLayout }
